﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Util
{
    public static class ApiResultHelper
    {
        public static ApiResult Success(dynamic data, int total = 0, string msg = "操作成功")
        {
            return new ApiResult
            {
                Code = 200,
                Total = total,
                Data = data,
                Msg = msg
            };
        }

        public static ApiResult Error(string msg = "操作失败")
        {
            return new ApiResult
            {
                Code = 500,
                Total = 0,
                Data = null,
                Msg = msg
            };
        }
    }

    public class ApiResult
    {
        public int Code { get; set; }
        public int Total { get; set; }
        public string Msg { get; set; }
        public dynamic Data { get; set; }
    }
}
